package com.ssy.lingxi.workflow.controller;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.workflow.api.model.vo.request.*;
import com.ssy.lingxi.workflow.api.model.vo.response.ComplexTaskDefVO;
import com.ssy.lingxi.workflow.api.model.vo.response.SimpleProcessDefVO;
import com.ssy.lingxi.workflow.service.IProcessQueryService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 流程步骤查询接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-04-29
 */
@RestController
@RequestMapping("/workflow/process/query")
public class ProcessQueryController {

    @Resource
    private IProcessQueryService processQueryService;

    /**
     * 查询复杂流程的任务定义
     * @param queryVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/complex", method = RequestMethod.POST)
    public Wrapper<ComplexTaskDefVO> findComplexTaskDefinitions(@RequestBody @Valid ComplexProcessQueryVO queryVO) {
        return processQueryService.findComplexTaskDefinitions(queryVO);
    }

    /**
     * 查询复杂流程的任务定义（多个会员角色）
     * @param queryVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/complex/roles", method = RequestMethod.POST)
    public Wrapper<ComplexTaskDefVO> findComplexTaskDefinitions(@RequestBody @Valid ComplexProcessWithRolesQueryVO queryVO) {
        return processQueryService.findComplexTaskDefinitions(queryVO);
    }

    /**
     * 查询单一的外部流程的定义
     * @param queryVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/external", method = RequestMethod.POST)
    public Wrapper<SimpleProcessDefVO> findSimpleExternalTaskDefinitions(@RequestBody @Valid ExternalProcessQueryVO queryVO) {
        return processQueryService.findSimpleExternalTaskDefinitions(queryVO);
    }

    /**
     * 查询单一的外部流程的定义（多个会员角色）
     * @param queryVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/external/roles", method = RequestMethod.POST)
    public Wrapper<SimpleProcessDefVO> findSimpleExternalTaskDefinitions(@RequestBody @Valid ExternalProcessWithRolesQueryVO queryVO) {
        return processQueryService.findSimpleExternalTaskDefinitions(queryVO);
    }

    /**
     * 查询单一的内部流程的定义
     * @param queryVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/internal", method = RequestMethod.POST)
    public Wrapper<SimpleProcessDefVO> findSimpleInternalTaskDefinitions(@RequestBody @Valid InternalProcessQueryVO queryVO) {
        return processQueryService.findSimpleInternalTaskDefinitions(queryVO);
    }
}
